<!--
 * @Description: 维修进度
 * @Author: Huang Junjie
 * @Date: 2021-06-01 17:26:07
 * @LastEditTime: 2021-09-09 10:21:05
 * @LastEditors: Liu Zhiwang
-->
<template>
  <div class="maintenance-progress-style">
    <div class="component-inner-div">
      <!-- 四角样式 -->
      <div class="the-four-border the-four-border-01" />
      <div class="the-four-border the-four-border-02" />
      <div class="the-four-border the-four-border-03" />
      <div class="the-four-border the-four-border-04" />
      <!-- 四角样式 -->

      <!-- 标题栏 -->
      <div class="title">
        <div class="point-icon" />
        <span>维修进度</span>
      </div>
      <!-- 标题栏 -->

      <!-- 列表 -->
      <el-scrollbar>
        <div class="content">
          <div class="inner-content">
            <div
              v-for="(item, index) in dataList"
              :key="`a${index}`"
              class="content-row"
            >
              <div class="content-left">
                {{ item.lineName }}
              </div>
              <div class="content-right">
                <el-progress class="progress-style" :stroke-width="14" :percentage="item.speedProcess" />
              </div>
            </div>
          </div>
        </div>
      </el-scrollbar>
      <!-- 列表 -->
    </div>
  </div>
</template>

<script>
import { getMaintenanceProgressDataList } from '@/api/jjxt/production-safety/segment-level-home';

export default {
  data() {
    return {
      // 返回值
      dataList: []
    };
  },
  mounted() {
    this.getMaintenanceProgressDataList(); // 查询维修进度信息列表
  },
  methods: {
    // 查询维修进度信息列表
    getMaintenanceProgressDataList() {
      getMaintenanceProgressDataList().then(res => {
        this.dataList = [];
        if (res.data.length > 5) {
          this.dataList = [
            { lineName: '', speedProcess: 0 },
            { lineName: '', speedProcess: 0 },
            { lineName: '', speedProcess: 0 },
            { lineName: '', speedProcess: 0 },
            { lineName: '', speedProcess: 0 },
            { lineName: '', speedProcess: 0 }
          ];
          setTimeout(() => {
            for (let i = 0; i < 6; i++) {
              const data = {
                lineName: res.data[i].lineName,
                speedProcess: res.data[i].speedProcess
              };
              this.$set(this.dataList, i, data);
            }
          }, 50);
        } else {
          for (let i = 0; i < res.data.length; i++) {
            const data = {
              lineName: '',
              speedProcess: 0
            };
            this.dataList.push(data);
          }
          setTimeout(() => {
            res.data.forEach((val, key) => {
              this.$set(this.dataList, key, val);
            });
          }, 50);
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.maintenance-progress-style {
  position: relative;
  color: white;
  width: 454px;
  box-sizing: border-box;
  overflow: hidden;
  .component-inner-div {
    border: 2px solid #122a57;
    height: 100%;
    background-color: rgba($color: #0a1944, $alpha: 0.9);
    box-sizing: border-box;
    .title {
      color: #3695FF;
      font-size: 20px;
      padding: 0;
      margin: 20px 16px 0 16px;
      padding-bottom: 16px;
      align-items: center;
      display: flex;
      border-bottom: 1px solid #0b62a3;
      .point-icon {
        background-color: #3695FF;
        height: 10px;
        width: 10px;
        margin: 0 10px 0 0;
      }
    }
    .el-scrollbar {
      position: absolute;
      top: 65px;
      left: 0;
      right: 0;
      bottom: 3px;
      ::v-deep .el-scrollbar__wrap {
        overflow-x: hidden;
      }
    }
    .content {
      width: 100%;
      padding: 16px 16px 0 16px;
      overflow: hidden;
      .inner-content {
        .content-row {
          height: 16px;
          margin-bottom: 16px;
          display: flex;
          .content-left {
            width: 130px;
          }
          .content-right {
            flex: 1;
            .progress-style ::v-deep .el-progress-bar__inner {
              background-image: linear-gradient(to right,  #029fe4, #05ffe1);
            }
            ::v-deep .el-progress {
              display: flex;
            }
            ::v-deep .el-progress__text {
              min-width: 54px;
              margin-top: -4px;
              font-family: SimSun;
              color: #ffffff;
              font-size: 12px;
            }
            ::v-deep .el-progress-bar__outer {
              background-color: #1b2649;
            }
          }
        }
      }
    }
  }
}
</style>
